<?php
require_once("includes/pagetop.php");

if(!(isset($_SESSION['Allyfolio_User_ID']) && trim($_SESSION['Allyfolio_User_ID'])!=""))
{
    redirect("index.php");
    exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>AllyFolio | SignUp </title>
<link href="css/style.css" rel="stylesheet" type="text/css" media="all"  />

<style type="text/css">
	table tr td div{ text-align:left !important; margin:0 !important}
	table tr{ vertical-align:top; padding:10px;}
</style>

<script src="js/jquery1.10.2.min.js"></script>
<script src="js/jquery.placeholder.js"></script>

<script src="js/general.js"></script>
<script src="js/functions.js"></script>


 <script>
$(document).ready(function(){
  $(".drop_btn").click(function(){
    $(".showbox").toggle();
  });
});
</script>
</head>
<body>


<br />
<br />
<br />

<div class="" align="center"><a href="#" class="topopup">Friend Request</a></div>
    <div id="toPopup" class="friendReq"> 
    <?php
    $condition=array();
    $query="select af_users.*,Unique_User_Friend_ID from af_users,af_user_friends where af_users.User_ID=af_user_friends.User_ID and af_user_friends.status=3 and User_Friend_ID='".$_SESSION['Allyfolio_User_ID']."' ";
        
    $query.=" order by requestdate desc " ;
    
    $friendsinfo=$pdodbobj->fetch_array($pdodbobj->query($query,$searchcond));
    
    ?>	
        <div class="close"></div>
        <div id="popup_content">  
        <div id="main_wrapper">
 		<div class="new_inb3"  style="width:auto;">
			<div style="width:462px; margin:0 auto" >
    			<div style="width:462px; margin:0 auto; position:relative; font-size:16px; color:#44c8f5">
    			    <div style="float:left">Friend Request</div>
    				<div style="float:left; margin-left:90px;"><img src="images/arrow.png" style="" /></div>
    				<div style="float:right; margin-right:5px; font-size:18px; font-weight:bold;">Settings</div>
    			    <div style="clear:both"></div>
    			</div>
    			
    			<table border="0" cellpadding="0" cellspacing="10" width="460px"  style="border:1px solid #abe1fa; padding:10px;" class="notu">
        			<?php
                    if(count($friendsinfo)>0)
                    {
                        for($i=0;count($friendsinfo);$i++)
                        {
                    ?>
                    <tr>
        			  <td width="60" style="padding:0px;"><div class="noti_pic"><a href="dna.php?t=<?php echo $friendsinfo[$i]['Allyfolio_User_ID']; ?>"> <img class="userpiclass" src="<?php if(trim($friendsinfo[$i]['Profile_Pic_Path'])!=""){ echo "uploads/users/".$friendsinfo[$i]['User_ID']."/".$friendsinfo[$i]['Profile_Pic_Path']; }else{ echo "images/default_user_pic.jpg"; } ?>" height="50px" width="50px" /></a></div></td>
        				<td width="220" valign="top" style="text-align:left;">
        				<div style="position:relative; top:-4px"><span class="noti_name" style="font-size:21px; color:#44c8f5 !important"><a href="dna.php?t=<?php echo $friendsinfo[$i]['Allyfolio_User_ID']; ?>"><?php echo $friendsinfo[$i]['Full_Name']; ?></p></a></span></div>
        				<div class="separator"></div>
        	               <span style="margin-top:5px; float:left; margin-right:5px; color:#44c8f5 !important"><?php echo $friendsinfo[$i]['Profile_Status']; ?></span>
                        </td>
        				<td width="138" align="right" id="requesttd_<?php echo $i; ?>">
        				
                        	<table border="0" width="100%">
                        	   <tr>
                        			<td rowspan="2" valign="middle"><input type="button" class="reject" value="Accept" onclick="return changeStatusFriendRequest(1,<?php echo $friendsinfo[$i]['Unique_User_Friend_ID']; ?>,<?php echo $i; ?>);" /></td>
                        			<td><input type="button" class="reject" value="Reject"  onclick="return changeStatusFriendRequest(4,<?php echo $friendsinfo[$i]['Unique_User_Friend_ID']; ?>,<?php echo $i; ?>);" /></td>
                        		</tr>
                        		<tr>
                        			<td><input type="button" class="reject" value="Block"  onclick="return changeStatusFriendRequest(0,<?php echo $friendsinfo[$i]['Unique_User_Friend_ID']; ?>,<?php echo $i; ?>);" /></td>
                        		</tr>
                        	</table>
        			   </td>
        			</tr>
                    <?php
                        }
                    }
                    else
                    {
                    ?>
        			<tr>
        			  <td>
        			  	<div style="height:105px" style="color: red;">No Friend Request!</div>
        			  </td>
        			</tr>
                    <?php
                    }
                    ?>
    			</table>
			    <div style="width:100%; text-align:right !important; color:#4ca1d4; width:462px; margin:0 auto;">Settings</div>
			</div>
	
		</div>
		
		<br />

		<div class="new_inb3" style="width:auto;">
			<div style="width:462px; margin:0 auto" >
			
			
			<table border="0" cellpadding="0" cellspacing="10" width="460px"  style="border:1px solid #abe1fa; padding:10px;" class="notu">
			<tr>
			  <td width="60" style="padding:0px;"><div class="noti_pic"></div></td>
				<td width="220" valign="top" style="text-align:left;">
				<div style="position:relative; top:-4px"><span class="noti_name" style="font-size:21px; color:#44c8f5 !important">ABC</span></div>
				<div class="separator"></div>

	<span style="margin-top:5px; float:left; margin-right:5px; color:#44c8f5 !important">2 Common Friend</span>
</td>
				<td width="138" align="right">
				
				
				

	
	

	<table border="0" width="100%">
	<tr>
			<td rowspan="2" valign="middle">&nbsp;</td>
			<td align="right"><input type="button" class="reject" value="Add Friend"  style="width:90px"/></td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
	</table>
					
				
	
	
	</td>
			</tr>
			<tr>
			  <td>
			  	<div style="height:105px"></div>
			  </td>
			</tr>
			<tr>
				<td colspan="4"><div style="width:100%; text-align:center !important; color:#4ca1d4; margin:0 auto;"><a href="#">More...</a></div></td>
			</tr>
			
			
			<!--<tr>
				<td colspan="3" align="center"><div style="margin-top:200px !important; width:100%; text-align:center !important; color:#4ca1d4;">More...</div></tr>
			</tr>-->
				
			</table>
			
			</div>
	
		</div>
	</div> 
        </div>
        </div>
        	<div class="loader"></div>
   	<div id="backgroundPopup"></div>



	
</body>
</html>
<script lang="javascript">
//<![CDATA[
    var requeststarr=new Array();
    requeststarr[1]="Accepted";
    requeststarr[0]="Blocked";
    requeststarr[4]="Rejected";
    function changeStatusFriendRequest(status,recordid,rowid)
    {
        if(recordid>0 && document.getElementById('requesttd_'+rowid))
        {
            $.ajax({
              cache:false,  
              async:false,
              url: "ajax_search/ajax_manageRequests.php?action=changereqstatus&recordid="+recordid+"&status="+status,
        	  success: function( data ) {
        	    if(trim(data)=="success")
                {
                    document.getElementById('requesttd_'+rowid).innerHTML="<b>"+requeststarr[status]+"</b>";
                    return false;
                }
                
        	  }
        	});
        }
    }
//]]>
</script>